<?php

declare(strict_types=1);

namespace app\shop\controller\api\data;

use think\Request;
use sheep\exception\SheepException;
use app\shop\model\data\Area as AreaModel;
use app\shop\controller\api\ShopBase;


class Area extends ShopBase
{

    public function index()
    {
        $list = AreaModel::sheepFilter()->with(['children' => function ($query) {
            return $query->field('id, pid, level, name')->with(['children' => function ($query) {
                return $query->field('id, pid, level, name');
            }]);
        }])->where('pid', 0)->order('id', 'asc')->field('id, pid, level, name')->select();

        return success('获取成功', $list);
    }
}
